#include "stdafx.h"
#include "msk1dockcontainer.h"


CMSK1DockContainer::CMSK1DockContainer(void)
{
}

int CMSK1DockContainer::Scale(int a0, int a1, int b0)
{
	return (a0 * a1) / b0;
}

LRESULT CMSK1DockContainer::DockContainerProc(
	HWND hWnd, 
	UINT msg, 
	WPARAM wParam, 
	LPARAM lParam
	)
{
	static CMSK1DockContainer* pWindow = NULL;
	static int nOldWidth = NULL;
	static int nOldHeight = NULL;

	if (pWindow)
	{
		switch (msg)
		{
		case WM_SIZE:
			int nWidth	= LOWORD(lParam);
			int nHeight = HIWORD(lParam);

			int b1 = Scale(nWidth, nOldWidth, pWindow->m_pPrimaryWnd->m_nWidth);
			int b3 = nWidth - b1;

			nOldWidth	= nWidth;
			nOldHeight	= nHeight;
			break;
		}

		return DefWindowProc(hWnd, msg, wParam, lParam);
	}

	if (msg == WM_NCCREATE) {
		LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);  
		pWindow = reinterpret_cast<CMSK1DockContainer *>(createStruct->lpCreateParams);

		return DefWindowProc(hWnd, msg, wParam, lParam);
	}

	return 0;
}

CMSK1DockContainer::~CMSK1DockContainer(void)
{
}

STDMETHODIMP CMSK1DockContainer::Initialize(
	CMSK1Window* pParentWnd
	)
{
	RECT rc;
	GetClientRect(pParentWnd->m_hWnd, &rc);

	CreateWindow(L"", L"DockContainer", WS_VISIBLE | WS_CHILD, 
		0, 0, RECTWIDTH(rc), RECTHEIGHT(rc), HWND_MESSAGE, 0, HINST_THISCOMPONENT, pParentWnd);

	return S_OK;
}